CLOSURE v1.01 - compute transitive closure

Revised 3-Apr-96. Copyright (c) 1996 by Rune Berg. TextTools Freeware.

Usage - Description - Example - Options - Limitations


USAGE

closure [log logfile] [option] key [graphfile] [to resultfile]


DESCRIPTION

closure builds a directed graph of strings from the contents of graphfile, computes the set of strings belonging to the transitive closure starting at key, and writes that set to resultfile.

key is a string.

graphfile is an ASCII text file containing lines with 0 .. 100 (by default, but see -i option) whitespace-separated fields; this is described in more detail in the documentation for tcols. Each such field is considered a 'string' in this discussion.

For each line with strings S1 S2 ... SN in graphfile, closure adds nodes S1 S2 ... SN, and edges S1->S2 ... S1->SN, to the directed graph.

For each line with just one string S1 in graphfile, closure adds a node S1 (but no edges) to the directed graph.

closure ignores empty (whitespace only) lines in graphfile.

closure ensures the directed graph never contains duplicate nodes or edges.

If key is a string equal one of the strings in graphfile, then closure writes, to resultfile, one string per line: key and all strings reachable by following paths of edges from key's node.

closure does not write duplicate strings.

If key is not equal to any of the strings in graphfile, resultfile will be empty.

If you don't specify graphfile, closure reads from standard input.
If you don't specify resultfile, closure writes to standard output.
If you don't specify logfile, closure writes error messages to standard error.


EXAMPLE

As an example, consider the (zoologically rather dubious) graphfile "fauna.txt":

	animal dog horse bird fish
	horse pony
	bird   sparrow eagle penguin
	fish whale shark
	shark  hammerhead great-white

For the command:

	closure fish fauna.txt

closure builds (internally) the graph:

	animal
	  |--> dog
	  |--> horse
	  |      +--> pony
	  |--> bird
	  |      |--> sparrow
	  |      |--> eagle
	  |      +--> penguin
	  +--> fish
	         |--> whale
	         |      |--> hammerhead
	         |      +--> great-white
	         +--> shark

and writes as result (though not necessarily in this order):

	fish
	whale
	shark
	hammerhead
	great-white


OPTIONS

-iC : Separate input fields by character C (except \). Use \t to form a tab.

-v : Print version banner and usage info to standard error (or logfile, if given), then exit.


LIMITATIONS

Input lines in graphfile must be no longer than 255 characters, not counting the end-of-line marker (newline).

When using the -i option, make sure that graphfile does not have unwanted spaces at the end of lines - closure regards trailing spaces as part of the last field.

closure cannot handle more than 256 graph nodes.
closure cannot handle more than 1024 graph edges.
closure cannot handle more than 5000 bytes of graph string data.


End of document